<?php /*a:8:{s:63:"/home/pirate/wx_manager/app/autoreply/view/add/autokey_add.html";i:1624952367;s:35:"../app/common/admin/lib/header.html";i:1622026634;s:36:"../app/common/admin/lib/sidebar.html";i:1606282475;s:39:"../app/autoreply/view/lib/top_menu.html";i:1606966586;s:39:"../app/appmsg/view/lib/single_info.html";i:1624952342;s:38:"../app/appmsg/view/lib/multi_info.html";i:1624952387;s:46:"../app/common/admin/lib/app_custom_select.html";i:1606381281;s:35:"../app/common/admin/lib/footer.html";i:1620273611;}*/ ?>
<?php
use app\common\config\autoreply_config;
use app\common\helper\index_msg_helper;
use app\common\helper\autoreply_helper;
use app\common\helper\appmsg_helper;
use app\common\model\User;
?>
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title><?php if($title): ?><?php echo htmlentities($title); ?>-<?php endif; ?>微信后台管理</title>
  <base href="<?php echo htmlentities(SITE_URL); ?>/"></base>
  <script type="text/javascript">
    var siteUrl = "<?php echo htmlentities(SITE_URL); ?>";
    var uploadUrl = "<?php echo htmlentities(UPLOAD_URL); ?>";
    var isAdmin = 1;
  </script>
  
  <link rel="stylesheet" type="text/css" href="./static/css/base.css" />
  <link rel="stylesheet" type="text/css" href="./static/css/admin/admin.css" />
  <link rel="stylesheet" href="/static/lib/layui-v2.5.4/css/layui.css" media="all">

  <?php if(in_array($module, explode(',', ',autoreply,appmsg,appmenu,appmenu_stat,key_stat,message,user'))): ?>
  <link rel="stylesheet" type="text/css" href="./static/css/admin/weixin.css" />
  <?php endif; ?>

  <script type="text/javascript" src="./static/js/jquery-1.7.1.min.js"></script>
  <script type="text/javascript" src="./static/js/jqueryui/1.8.11/jquery-ui.js"></script>
  <script type="text/javascript" src="./static/js/common.js"></script>
  <script type="text/javascript" src="./static/js/admin/admin.js"></script>
  <script type="text/javascript" src="./static/js/qDialog.js"></script>
  <script type="text/javascript" src="./static/js/zclip/jquery.zclip.min.js"></script>
  <script type="text/javascript" src="./static/js/zclip/ZeroClipboard.js"></script>
  <link rel="shortcut icon" href="./favicon.ico">
  <script src="/static/lib/layui-v2.5.4/layui.js?v=1.0.4" charset="utf-8"></script>
  <script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
  <link rel="stylesheet" href="/static//css/admin/weiboface.css" type="text/css" />
  <script type="text/javascript" src="/static//js/weiboface.js"></script>
  <!--[if IE 6]>
  <script src="./static/js/DD_belatedPNG_0.0.8a-min.js"></script>
  <script>
    DD_belatedPNG.fix('.logo a,.n-icon');
  </script>
  <![endif]-->
  <script>
  $(function(){
    // 页面高度
    var windowHeight = $(window).height();
    var domHeight = $(document).height();
    if (domHeight > windowHeight) {
      windowHeight = domHeight;
    }
    if ($(".inner-center").height() < windowHeight - 66) {
      $(".inner-center").css('min-height', windowHeight - 66);
      //$('body').css('overflow', 'hidden');
    }
    
    // 用户设置浮层
    $(".js_userSetBtn").click(function(e){
     e.preventDefault();
     e.stopPropagation();
     
     $(".js_cardSetBox").addClass('hidden');
     if ($(".js_userSetBox").hasClass('hidden')) {
       $(".js_userSetBox").removeClass('hidden');
     } else {
       $(".js_userSetBox").addClass('hidden');
     }
    });

      // 公众号下拉浮层
      $(".js_cardSetBtn").click(function(e){
          e.preventDefault();
          e.stopPropagation();

          $(".js_userSetBox").addClass('hidden');
          if ($(".js_cardSetBox").hasClass('hidden')) {
              $(".js_cardSetBox").removeClass('hidden');
          } else {
              $(".js_cardSetBox").addClass('hidden');
          }
      });

      // 表情初始化
      weiboFaceInit({
          //emotionUrl: "javascript:;",
          data: <?php echo config('emotion.weixin_emotions'); ?>
      });
  });
  </script>
</head>
<body>

<div id="wrap">
  <div class="header">
    <div class="htop clearfix">
      
      <h1 class="logo left" style="width:300px;"><a href="<?php echo url('admin'); ?>">微信后台管理 [<?php echo htmlentities($open_card_info['title']); ?>] </h1>
      <?php if($user_id > 0): ?>
        
        <div class="infotop">
          <a href="javascript:void(0);" class="userpic"></a>
          <span class="username-right js_userSetBtn">
            <a href="javascript:;" class="username"><?php echo User::display_name($user_id); ?></a>
            <span class="arrowtop">
              <i></i>
            </span>
          </span>
          <div class="poptop poptop-user js_userSetBox hidden" style="background:white;">
            <em>◆</em>
            <ul>
              
              <li><a href="<?php echo url('home'); ?>">回前台</a></li>
              <li><a href="<?php echo url('/admin/logout/index'); ?>">退出</a></li>
            </ul>
          </div>
        </div>
      <?php else: ?>
        <div class="htop-login right">
          <a href="<?php echo url('admin'); ?>">登录</a>
          <a href="<?php echo url('user/register'); ?>">注册</a>
        </div>
      <?php endif; ?>
    </div>
  </div>
  <div class="container clearfix">
    <div class="sidebar left">
  <ul class="sidenav">
  <!-- {an_dump($sidebar_menu_list)} -->
    <?php foreach($sidebar_menu_list as $k=>$v): ?>
    <li class="js_topMenu">
      <a href="javascript:;"><?php echo htmlentities($v['title']); ?><em></em></a>
      <?php if($v['children']): ?>
      <ul class="sidenav2" style="display:none;">
        <?php foreach($v['children'] as $k1=>$v1): ?>
        <li class="<?php echo htmlentities($v1['curr']); ?>">
          <a href="<?php echo htmlentities($v1['url']); ?>" data-qian="vmodule::<?php echo htmlentities($v1['module']); ?> vcontroller::<?php echo htmlentities($v1['controller']); ?> vaction::<?php echo htmlentities($v1['action']); ?> ___ module::<?php echo htmlentities($module); ?> controller::<?php echo htmlentities($controller); ?> action::<?php echo htmlentities($action); ?> __ vextra::<?php echo htmlentities($v1['extra_res']); ?> extra::<?php echo htmlentities($extra_res); ?> vcurr::<?php echo htmlentities($v1['curr']); ?>"><?php echo htmlentities($v1['title']); ?>&nbsp;&nbsp;<i style="display:none;" style="color:red">(0)</i></a>
        </li>
        <?php endforeach; ?>
      </ul>
      <?php endif; ?>
    </li>
    <?php endforeach; ?>
  </ul>
</div>
<script>
$(function(){
  $('.js_topMenu').click(function(e){
    
    var s=e.target || e.srcElement;
    if ($(s).parents(".sidenav2").size()>0) {
      return;
    }

    $(this).siblings().removeClass('curr')
    $(this).siblings().find('ul:visible').slideUp();
    if (!$(this).find('ul:visible').length) {
      $(this).find('ul').slideDown();
      $(this).addClass('curr');
    } else {
      $(this).find('ul').slideUp();
      $(this).removeClass('curr');
    }
  });
  
  $(".sidenav2 li").each(function(i, n){
    if ($(this).hasClass('curr')) {
      $(this).closest('ul').show();
      $(this).closest('.js_topMenu').addClass('curr');
    };
  });
});
</script>
    <div class="center">
      <div class="inner-center">
<?php echo htmlentities($type = autoreply_config::$autoreply_type); ?>
<div class="replynav">
  <ul class="rnav-list clearfix">
    <?php foreach($type as $k=>$v): ?>
      <li <?php if($k == $autoreply_type): ?> class="curr" <?php endif; ?>><a href='<?php echo url("/autoreply/admin/$k"); ?>'><?php echo htmlentities($v); ?></a></li>
    <?php endforeach; ?>
  </ul>
</div>
<div class="rlbox">
  <!--start:关键词添加-->
  <div class="page-header clearfix">
    <div class="page-header-intro left">在这里设置：通过匹配用户输入的内容，来自动回复<br>例如：当用户输入“会员”，来找是否设置了会员关键词，如果有，则回复对应的信息</div>
    <a href="<?php echo url('/autoreply/admin/3'); ?>" class="btn btn-default btn-sm right">&lt;&nbsp;返回关键词自动回复</a>
  </div>
  <form action="<?php echo url('/autoreply/save/3'); ?>" method="post" class="js_createForm">
    <table class="list-table add-table table table-sm" cellpadding="0" cellspacing="0">
      <thead>
        <tr>
          <th>规则名：<span style="font-weight:normal; color:#aaa;">（最多60个字） </span></th><!-- width="232"-->
          <th>&nbsp;</th>
        </tr>
        <tr>
          <td colspan="2" style="padding:10px 10px 10px 20px;">
            <input type="hidden" name="id" value="<?php echo htmlentities($key_info['id']); ?>">
            <input type="text" value="<?php echo htmlentities($key_info['title']); ?>" class="txt1 js_title">
          </td>
        </tr>
        <tr>
          <th style="width:229px">关键词</th>
          <th>关键词对应的回复</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td colspan="2">
            <div class="clearfix" style="min-height:200px;">
              <div class="keyword-area left">
                <p>在这里输入要匹配的关键词，<br>每个关键词最多30个字</p>
                <div class="js_keyBox">
                  <?php echo htmlentities($key_list = autoreply_helper::get_autoreply_key_list($key_info['id'], 2)); if($key_list): foreach($key_list as $k=>$v): ?>
                      <div class="per-keywords js_perKeyBox" data-id="<?php echo htmlentities($v['id']); ?>" data-match="<?php echo htmlentities($v['match_type']); ?>">
                        <i class="icon-reply-del js_deleteKey"></i>
                        <input type="text" value="<?php echo htmlentities($v['title']); ?>" class="txt1 js_key" style="width:120px;">
                      </div>
                    <?php endforeach; ?>
                  <?php endif; ?>
                </div>
                <div>
                  <a href="javascript:void(0);" class="btn btn-success btn-sm js_addNewKey"><i class="icon-add"></i>新增关键词</a>
                </div>
              </div>
              <i class="icon-go left" style="top:0px;"></i>
              <div class="add-reply-list left js_outDiv">
                <p>在这里输入左侧的关键词对应的回复的信息<br>可以加多条回复，左侧相对应的关键词会从这里随机选一条</p>
                <?php echo htmlentities($auto_content_list = autoreply_helper::get_autoreply_content_list($key_info['id'], 2)); ?>
                <!--<?php echo htmlentities($content_count = count($auto_content_list)); ?>-->
                <?php if($auto_content_list): foreach($auto_content_list as $k=>$v): ?>
                    <div class="reply-area js_contentDiv" data-id="<?php echo htmlentities($v['id']); ?>" data-type="<?php echo htmlentities($v['content_type']); ?>" <?php if($v['content_type'] != 1): ?>data-content='<?php echo htmlentities($v['content']); ?>' style="width:260px;"<?php endif; ?>>
                      <i class="icon-reply-del js_deleteContent"></i>
                      <?php if($v['content_type'] == 0): ?>
                        {widget model="index_msg" func="get_info" file="index_msg_info.html"}
                      <?php elseif($v['content_type'] == 1 || $v['content_type'] == 40): ?>
                        <!--/*<textarea name="info[cinfo{$k][content]"><?php echo htmlentities($v['content']); ?></textarea>*/}-->
                        <div contentEditable="true" class="content-textarea js_replyContent"><?php echo htmlentities($v['content']); ?></div>
                        <div class="txt-options clearfix">
                          <p class="txt-count right js_fontNumBox">还可输入<span style="color:green; font-weigth:bold;">300</span>字</p>
                        </div>
                      <?php elseif($v['content_type'] == 2): ?>
                        <?php echo htmlentities($list = appmsg_helper::get_list(['type'=>1, 'id' => $v['content']])); ?>
                        <?php echo htmlentities($flag = 1); foreach($list['data'] as $k=>$v): ?>
<div class="showfill" style="float:none;">
  <h3 class="tit"><?php echo htmlentities($v['title']); ?></h3>
  <span class="date"><?php echo time_format($v['add_time'], 'Y-m-d'); ?></span>
  <div class="withmap"><?php if($v['cover']): ?><img src="<?php echo _image($v['cover'], 'small'); ?>" alt="封面图"><?php endif; ?></div>
  <p class="summary"><?php echo htmlentities($v['intro']); ?></p>
</div>
<?php endforeach; if(!isset($flag)): ?>
<div id="pages"></div>
<?php endif; elseif($v['content_type'] == 3): ?>
                        <?php echo htmlentities($list = appmsg_helper::get_list(['type'=>2, 'id' => $v['content']])); ?>
                        <?php echo htmlentities($flag = 1); foreach($list['data'] as $k=>$v): ?>
<div class="showmulti">
  <ul class="multi-list">
    <li>
      <div class="big">
        <span class="date"><?php echo time_format($v['add_time'], 'Y-m-d'); ?></span>
        <div class="withmap"><?php if($v['cover']): ?><img src="<?php echo _image($v['cover'], 'small'); ?>" alt=""><?php endif; ?><h3 class="tit2"><?php echo htmlentities($v['title']); ?></h3></div>
      </div>
    </li>
    <?php if(empty($v['son_list'])): ?>
      <?php echo htmlentities($son_list = appmsg_helper::get_merge_appmsg_list($v['id'], 1)); else: ?>
      <?php echo htmlentities($son_list = $v['son_list']); ?>
    <?php endif; foreach($son_list as $k1=>$v1): if($k1 >= 1): ?>{continue}<?php endif; ?>
      <li>
        <div class="small clearfix">
          <h3 class="tit3 left"><?php echo htmlentities($v1['title']); ?></h3>
          <div class="withmap2 right"><?php if($v1['cover']): ?><img src="<?php echo _image($v1['cover'], 'small_equal'); ?>" alt=""><?php endif; ?></div>
        </div>
      </li>
    <?php endforeach; if(count($son_list) < 1): ?>
    <li>
      <div class="small clearfix">
        <h3 class="tit3 left">--</h3>
        <div class="withmap2 right">&nbsp;</div>
      </div>
    </li>
    <?php endif; ?>
  </ul>
</div>
<?php endforeach; if(!isset($flag)): ?>
<div id="pages"></div>
<?php endif; elseif($v['content_type'] == 4): ?>
                        <!---->
                      
                      <?php elseif($v['content_type'] == 10): ?>
                        <!---->
                      
                      <?php elseif($v['content_type'] == 20): ?>
                        <!---->
                      <?php endif; ?>
                    </div>
                  <?php endforeach; ?>
                <?php endif; ?>
                <p class="js_addP"><a href="javascript:void(0);" class="btn btn-success btn-sm js_addNewContent"><i class="icon-add"></i>新增一条回复</a></p>
              </div>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
    <div><button type="submit" class="btn btn-success js_submit">&nbsp;&nbsp;确&nbsp;认&nbsp;&nbsp;</button></div>
  </form>
  <!--end:关键词添加-->
</div>


<?php echo htmlentities($select_app_list = config('admin.select_app_list')); ?>
<?php echo htmlentities($select_query    = config('admin.select_query')); ?>
<div class="hidden js_AppCustomHideBox">
  <div class="float-define">
    <table>
      <tr class="float-set-rule2">
        <td valign="top" align="right" style="width:116px;"><label for="">回复类型：</label></td>
        <td>
          <p>将从
            <select name="appType" class="js_typeSelect">
              <?php foreach($select_app_list as $k=>$v): ?>
              <option value="<?php echo htmlentities($k); ?>"><?php echo htmlentities($v['title']); ?></option>
              <?php endforeach; ?>
            </select>
            <?php foreach($select_app_list as $k=>$v): if(empty($v['child'])): ?>{continue}<?php endif; ?>
            <select name="appSubType" class="js_sonTypeSelect<?php echo htmlentities($k); ?> js_sonTypeSelect hidden">
              <?php foreach($v['child'] as $k1=>$v1): ?>
              <option value="<?php echo htmlentities($k1); ?>"><?php echo htmlentities($v1); ?></option>
              <?php endforeach; ?>
            </select>
            <?php endforeach; ?>中
            <span class="float-set-toadd js_addMoreBox">没有合适的，去<a target="_blank" href="<?php echo url('/article/admin/add'); ?>">添加</a></span>
          </p>
          <p>取出
            <select name="" class="js_queryType">
              <?php foreach($select_query as $k=>$v): ?>
              <option value="<?php echo htmlentities($k); ?>"><?php echo htmlentities($v); ?></option>
              <?php endforeach; ?>
            </select>

            <input type="text" value="1" class="js_queryNum"> 条
          </p>
        </td>
      </tr>

      <tr class="js_customSelectBox hidden">
        <td valign="top" align="right"><label for="">选择内容：</label></td>
        <td>
          <div class="float-choose clearfix">
            <div class="float-choose-l left">
              <div class="search-level1 clearfix">
                <input type="text" class="left" id="keywords">
                <button type="button" id="keysBtn" class="btn btn-success btn-xs right">搜索</button>
              </div>
              <div id="js_loadBox">

              </div>
            </div>
            <div class="float-choose-arrow left"></div>
            <!--start:已选择的资源-->
            <div class="float-choose-l right">
              <div class="float-choose-title clearfix">已选择的内容：</div>
              <ul class="float-choose-list" id="js_selBox">
              </ul>
            </div>
            <!--end:已选择的资源-->
          </div>
        </td>
      </tr>
    </table>
  </div>
</div>
<script type="text/javascript" src="./static/js/fcd/jquery.fcbkcomplete.js"></script>
<link rel="stylesheet" type="text/css" href="./static/js/fcd/style.css" />
<script type="text/javascript" src="./static/js/appCustomSelect.js"></script>
<script>
var fillTitle = "标题 （必填）";
$(function(){
  
  //inputPlaceHold($(".js_title"), fillTitle, "<?php echo htmlentities($key_info['title']); ?>");
  
  // 初始化字数
  $.each($(".js_replyContent"), function(i, n){
    syncNum($(this), $(this).next().find(".js_fontNumBox"), 300);
    
    $(this).keyup(function(){
     syncNum($(this), $(this).next().find(".js_fontNumBox"), 300);
    });
  })
  
  // 添加关键词
  $(".js_addNewKey").click(function(){
    $(".js_keyBox").append('<div class="per-keywords js_perKeyBox" data-match="1"><i class="icon-reply-del js_deleteKey"></i><input type="text" value="" class="txt1 js_key" style="width:120px;"></div>');
  });
  
  // 删除一个关键词
  $('.js_deleteKey').live('click', function(e){
    var thisObj = $(this);
    showConfirm('您确定要删除这个关键词吗?', 1, function(){
      thisObj.closest('.js_perKeyBox').remove();
    });
  });
  
  // 添加新的回复
  $('.js_addNewContent').click(function(e){
    var thisObj = $(this);
    var _offset = thisObj.offset();
    var _top = _offset.top+44;
    var _left = _offset.left;

    $(".js_menuSetBox").find(".js_menuLinkBtn").remove();
    $(".js_menuSetBox .inner-linkpop").find("i").css({ 'left':'12px' }).end().find("b").css({ 'left':'12px' });
    $(".js_menuSetBox").css({ 'top':_top+'px', 'left':_left+'px' }).show();
    
  });
  
  // 关联到首页
  $(".js_menuIndexBtn").live('click', function(){
    $(".js_menuSetBox").hide();
    showConfirm('您确定要关联此菜单到微官网首页吗?', 1, function(){
      if (typeof qDialog != 'undefined') {
        qDialog.close();
      }
      
      showLoading();
      $.post(siteUrl+'/index_msg/admin/load_index_msg', { }, function(json){
        hideLoading();  
        if (json.info != 'ok') {
          showMsg(json.info);
          return;
        }
        
        var html = '<div class="reply-area js_contentDiv" data-type="0" data-content="-1"><i class="icon-reply-del js_deleteContent"></i>';
        html += json.html;
        html += '</div>';
        
        $(html).insertBefore('.js_addP').children('div').css({ 'float':'none' }).end().css({ 'width':'260px' }).children('.icon-select').remove();
        
        bindDeleteReplyEvent();
      }, 'json');
    });
  });
  
  // 添加文本
  $(".js_menuTextBtn").click(function(){
    $(".js_menuSetBox").hide();
    var html = '<div class="reply-area js_contentDiv" data-type="1"><i class="icon-reply-del js_deleteContent"></i>\
       <div contentEditable="true" class="content-textarea js_replyContent"></div>\
       <div class="txt-options clearfix">\
      <p class="txt-count right js_fontNumBox">还可输入<span style="color:green; font-weigth:bold;">300</span>字</p>\
    </div></div>';
    $(html).insertBefore('.js_addP');
    //consoleLog($(html));
    // 字数
    $(".js_replyContent:last").keyup(function(){
     syncNum($(this), $(this).next().find(".js_fontNumBox"), 300);
    });
    
    bindDeleteReplyEvent();
  });

    // 添加活动
    $(".js_menuActivityBtn").click(function(){
        $(".js_menuSetBox").hide();
        var html = '<div class="reply-area js_contentDiv" data-type="40"><i class="icon-reply-del js_deleteContent"></i>\
       <div contentEditable="true" class="content-textarea js_replyContent"></div>\
       <div class="txt-options clearfix">\
      <p class="txt-count right js_fontNumBox">还可输入<span style="color:green; font-weigth:bold;">300</span>字</p>\
    </div></div>';
        $(html).insertBefore('.js_addP');
        //consoleLog($(html));
        // 字数
        $(".js_replyContent:last").keyup(function(){
            syncNum($(this), $(this).next().find(".js_fontNumBox"), 300);
        });

        bindDeleteReplyEvent();
    });

    // 添加图文
  $(".js_menuSingleBtn, .js_menuMultiBtn").live('click', function(){
    $(".js_menuSetBox").hide();
    
    if (typeof qDialog != 'undefined') {
      qDialog.close();
    }
    var msgType = 2;
    if ($(this).hasClass("js_menuMultiBtn")) {
      msgType = 3;
    }
    
    var html  = '<div class="float-prompt-con"><p class="float-pic-info">请选择关链到已有的图文信息，或者去&nbsp;<a target="_blank" href="'+siteUrl+'/appmsg/add/'+(msgType-2)+'">添加新的图文信息</a></p>';
        html += '<div class="js_msgList"><img src="'+siteUrl+'/images/loading2.gif"></div></div>';
    ace.dialog({
      'title':'选择图文信息',
      'content':html,
      'init':function(){
        $(".aceDialog").width(960);
        $(".aceContent").height(400);
        $(".aceContent").css('overflow', 'auto');
        
        setTimeout(function(){
          resetDialogPosition($(".aceDialog"));
        }, 10);
        $(".js_msgList").load(siteUrl+'/appmsg/admin/get_msg_list', { 'type':msgType-1 }, function(){
          bindMsgEvent(msgType);
        });
        
        $(".js_msgList .page>a").live('click', function(e){
          e.preventDefault();
          var _href = $(this).attr('href');
          $(".js_msgList").load(_href, { 'type':msgType-1 }, function(){
            bindMsgEvent(msgType);
          });
        });
      },
      'okValue':''
    });
  });
  
  // 添加纯图片
  $(".js_menuImgBtn, .js_menuVoiceBtn").live('click', function(e){
    e.stopPropagation();
    $(".js_menuSetBox").hide();
    
    if (typeof qDialog != 'undefined') {
      qDialog.close();
    }
    var msgType = 3;
    var contentType = 10;
    var notice = '图片'
    if ($(this).hasClass('js_menuVoiceBtn')) {
      contentType = 20;
      notice = '声音';
    }
    
    var html  = '<div class="float-prompt-con"><p class="float-pic-info">请选择关链到已有的'+notice+'信息，或者去&nbsp;<a target="_blank" href="'+siteUrl+'/appmedia/add/'+(msgType-2)+'">添加新的'+notice+'信息</a></p>';
        html += '<div class="js_msgList"><img src="'+siteUrl+'/static/images/loading2.gif"></div></div>';
    ace.dialog({
      'title':'选择纯'+notice+'信息',
      'content':html,
      'init':function(){
        $(".aceDialog").width(960);
        $(".aceContent").height(400);
        $(".aceContent").css('overflow', 'auto');
        
        setTimeout(function(){
          resetDialogPosition($(".aceDialog"));
        }, 10);
        $(".js_msgList").load(siteUrl+'/appmedia/admin/get_media_list', { 'type':contentType }, function(){
          bindMsgEvent(contentType);
          bindVoiceEvent();
        });
        
        $(".js_msgList .page>a").live('click', function(e){
          e.preventDefault();
          var _href = $(this).attr('href');
          $(".js_msgList").load(_href, { 'type':contentType }, function(){
            bindMsgEvent(contentType);
            bindVoiceEvent();
          });
        });
      },
      'okValue':''
    });
  });
  
  // 添加智能回复
  $(".js_menuCustomBtn").click(function(){
    $(".js_menuSetBox").hide();
    
    if (typeof qDialog != 'undefined') {
      qDialog.close();
    }
    var msgType = 4;
    var oldHtml = $(".js_AppCustomHideBox").html();
    $(".js_AppCustomHideBox").html('');
    var tmpSelectData = [];
    qDialog = null;
    ace.dialog({
      'title':'智能回复',
      'content':oldHtml,
      'init':function(){
        $(".aceDialog").width(680);
        //$(".aceContent").height(400);
        $(".aceContent").css('overflow', 'auto');
        
        var currType    = $(".js_typeSelect").val();
        var currSonType = $(".js_sonTypeSelect"+currType).val();
        //var currSearch  = $.trim($("#js_searchInput").val());
        var queryType   = $.trim($(".js_queryType").val());
        var queryNum   = $.trim($(".js_queryNum").val());
        $(".js_typeSelect").change(function(){
          currType = $(this).val();
          $(".js_sonTypeSelect").hide();
          $(".js_sonTypeSelect"+currType).show();
          againLoad();
          changeAddUrl();
        });
        
        $(".js_sonTypeSelect").change(function(){
          againLoad();
          changeAddUrl();
        });
        
        $(".js_queryType").change(function(){
          queryType   = $.trim($(this).val());
          if (queryType == 2) {
            $(".js_customSelectBox").show();
            $(".js_queryNum").hide();
          } else {
            $(".js_customSelectBox").hide();
            $(".js_queryNum").show();
          }
          setTimeout(function(){
            resetDialogPosition($(".aceDialog"));
          }, 10);
          againLoad();
        });
        
        // 拖动选择的顺序
        $(".float-choose-list").sortable({ 
          axis: "y" ,
          opacity: 0.6,
          stop:function(){
          }
        });
        
      },
      'ok':function(){
        if ($(".aceDialog .okBtn").attr('is_post') == 1) {
          showMsg('提交中，请稍候...');return;
        }
        var currType    = $(".js_typeSelect").val();
        var currSonType = $(".js_sonTypeSelect"+currType).val();
        var queryType   = $.trim($(".js_queryType").val());
        var queryNum    = $.trim($(".js_queryNum").val());
        //var currSearch  = $.trim($(".js_searchInput").val());
        var queryInfo = [];
        $(".js_preCustom").each(function(i){
          queryInfo[i] = $(this).attr('data-id');
        });
        var msgTitle = '内容库';
        if (currType == 2) {
          msgTitle = '活动';
        }
        if (queryType == 2) {
          queryNum = queryInfo.length;
        }
        if (queryNum < 1) {
          showMsg('请至少取出一条'+msgTitle+'数据');
          return;
        }
        if (queryNum > 10) {
          showMsg(msgTitle+'数量不能多于10条');
          return;
        }
        
        var postData = { 'type':currType, 'sub_type':currSonType, 'query_type':queryType, 'query_num':queryNum, 
            'info':queryInfo, 'return_son_list':1 };
        $(".aceDialog .okBtn").text('提交中...').attr('is_post', 1);
        $.post(siteUrl+'/appmsg/admin/automsg', postData, function(json){
          $(".aceDialog .okBtn").text('确定').attr('is_post', 0);
          if (json.info != 'ok') {
            showMsg(json.info);
            return false;
          }
          
          // 成功后的操作
          var html = '<div class="reply-area js_contentDiv" data-type="'+msgType+'" data-content=\''+json.content+'\'><i class="icon-reply-del js_deleteContent"></i>';
          html += json.html;
          html += '</div>';
          
          $(html).insertBefore('.js_addP').children('div').css({ 'float':'none' }).end().css({ 'width':'260px' }).children('.icon-select').remove();
          
          bindDeleteReplyEvent();
          
          $(".js_AppCustomHideBox").html(oldHtml);
          qDialog.close();
        }, 'json');
      },
      'close':function(){
        $(".js_AppCustomHideBox").html(oldHtml);
        //qDialog.close();
      }
    });
  });
  
  // 提交回复
  var isPost = 0;
  $('.js_submit').click(function(e){
    e.preventDefault();
    if (isPost == 1) {
      showMsg('数据提交中，请稍候 ...');
      return false;
    }
    
    var id    = $(":input[name='id']").val();
    var title = $.trim($(".js_title").val());
    if (!title || title == fillTitle) {
      showMsg('请为关键词起一个规则名，最多60个字');
      return;
    }
    if (getNum($(".js_title"), 1) > 60) {
      showMsg('规则名不能超过60个字');
      return;
    }
    
    // 每个关键词
    var keyNum = 0;
    var keyInfo = [];
    var overLimitKey = 0;
    $('.js_perKeyBox').each(function(){
      var thisObj = $(this);
      
      var id        = thisObj.attr('data-id');
      var key       = $.trim(thisObj.find(".js_key").val());
      var matchType = thisObj.attr('data-match');
      if (!key) {
        return;
      }
      if (getNum(thisObj.find(".js_key"), 1) > 30) {
        overLimitKey = 1;
        return;
      }
      
      keyInfo[keyNum] = { 'id':id, 'title':key, 'match_type':matchType };
      
      keyNum++;
    });
    if (overLimitKey > 0) {
      showMsg('每个关键词不能超过30字');
      return;
    }
    if (keyNum == 0) {
      showMsg('请至少填写一个关键词');
      return;
    }
    
    // 每条回复
    var num = 0;
    var info = [];
    var overLimit = 0;
    $('.js_contentDiv').each(function(){
      var thisObj = $(this);
      var contentId      = thisObj.attr('data-id');
      var type    = thisObj.attr('data-type');
      var content = '';
      if (type == 1 || type == 40) {
        content = $.trim(thisObj.find('.js_replyContent').html());
      } else {
        content = thisObj.attr('data-content');
      }
      //console.log(content, type);
      if (!content) {
        return;
      }
      if (type == 1  || type == 40) {
        var fontNum = getNum(thisObj.find('.js_replyContent'));
        if (fontNum > 300) {
          overLimit = 1;
          return;
        }
        if (fontNum < 0) {
          reutrn;
        }
        
        //console.log(fontNum);
      }
      
      info[num] = { 'id':contentId, 'type':type, 'content':content };
      num++;
    });
    if (overLimit > 0) {
      showMsg('每条回复的内容不能超过300字');
      return;
    }
    if (num == 0) {
      showMsg('请至少填写一条回复内容');
      return;
    }
    
    isPost = 1;
    var postData = { 'id':id, 'title':title, 'key':keyInfo, 'info':info };
    $.post(siteUrl+'/autoreply/save/3', postData, function(json){
      isPost = 0;
      if (json.info != 'ok') {
        showMsg(json.info);
        return;
      }
      
      //showMsg('成功', 1);
      location.href = siteUrl+'/autoreply/admin/3.html';
    }, 'json');
  });
  
  bindDeleteReplyEvent();
});

// 图文列表加载后的事情绑定
function bindMsgEvent(msgType)
{
  $(".js_msgList>li").unbind('click');
  // 选择某一条图文做为回复
  $(".js_msgList>li").bind('click', function(e){
    e.preventDefault();
    e.stopPropagation();
    var thisObj = $(this);
    if (!thisObj.hasClass('curr')) {
      var id = thisObj.attr('data-id');
      if (!id) {
        showMsg('请选择一条信息');
        return false;
      }
      
      showConfirm('您确定要选择该图文信息吗?', 1, function(){
        if ($(".js_contentDiv[data-content='"+id+"']").length > 0) {
          showMsg('已经选择了该条图文信息，无须多次选择');
          return;
        }
        
        var html = '<div class="reply-area js_contentDiv" data-type="'+msgType+'" data-content="'+id+'"><i class="icon-reply-del js_deleteContent"></i>';
        html += thisObj.html();
        html += '</div>';
        
        $(html).insertBefore('.js_addP').children('div').css({ 'float':'none' }).end().css({ 'width':'260px' }).children('.icon-select').remove();
        
        bindDeleteReplyEvent();
        
        qDialog.close();
      });
    }
  });
}

// 绑定回复信息删除事件
function bindDeleteReplyEvent()
{
  $('.js_deleteContent').unbind('click')
//删除一条回复
  $('.js_deleteContent').bind('click', function(e){
    var thisObj = $(this);
    showConfirm('您确定要删除这条回复吗?', 1, function(){
      thisObj.closest('.js_contentDiv').remove();
    });
  });
}

// 加载自定义浮层信息列表
function loadCustomSelectList(currType, currSonType, currSearch)
{
  var _url = siteUrl+'/';
  if (currType == 1) {
    _url += 'article/admin/load_article?per_page=8&title='+currSearch;
  } else if (currType == 2) {
    _url += 'article/admin/load_article?per_page=8&type='+currType+'&title='+currSearch;
  }
  $(".js_loadBox").load(_url, {  }, function(){
    setTimeout(function(){
      resetDialogPosition($(".aceDialog"));
    }, 10);
  });
}
//绑定语音事件
function bindVoiceEvent()
{
  $(".js_perVoiceMedia").unbind('click');
  
  $(".js_perVoiceMedia").bind('click', function(e){
    e.stopPropagation();
    var id = $(this).attr('data-id');
    
    document.getElementById('js_noticeMusic'+id).play();
  });
}
</script>
      </div>
      
    </div>
  </div>
      
      <div class="linkpop js_menuSetBox" style="display:none;">
          <div class="inner-linkpop">
      <span>
        <i class="arrowpop"></i>
        <b class="arrowpop2"></b>
      </span>
              <p class="options-list">
                  <!--<a class="js_menuIndexBtn" href="javascript:void(0);">关联到微官网</a>-->
                  <a class="js_menuLinkBtn" href="javascript:void(0);">跳转到网页</a>
                  <a class="js_menuTextBtn" href="javascript:void(0);">纯文字回复</a>
                  <a class="js_menuSingleBtn" href="javascript:void(0);">单条图文信息</a>
                  <a class="js_menuMultiBtn" href="javascript:void(0);">多条图文信息</a>
                  <a class="js_menuActivityBtn" href="javascript:void(0);">活动回复</a>
                  <!--{*<a class="js_menuImgBtn" href="javascript:void(0);">图片</a>-->
                  <!--<a class="js_menuVoiceBtn" href="javascript:void(0);">声音</a>-->
                  <!--<a class="js_menuCustomBtn" href="javascript:void(0);">智能回复</a>*}-->
              </p>
          </div>
      </div>

</div>
<span class="goTop go-top-box" style="display:none;"></span>
<script>
$(function(){
  // to-top
  goTopEx($(".goTop")[0]);
  // 点击其他地方隐藏弹层
  $(document).click(function(e){
    var s=e.target || e.srcElement;
    // 隐藏图文信息的编辑框
    if (!$(s).is('.js_showSetBoxBtn') && !$(s).is('.js_setBox') && $(s).parents(".js_setBox").size()<1) {
      $(".js_setBox").addClass('hidden');
    }
    
    // 隐藏个人设置弹框
    if (!$(s).is('.js_userSetBtn') && !$(s).is('.js_userSetBox') && $(s).parents(".js_userSetBox").size()<1) {
      $(".js_userSetBox").addClass('hidden');
    }
    
    // 隐藏个人设置弹框
    if (!$(s).is('.js_cardSetBtn') && !$(s).is('.js_cardSetBox') && $(s).parents(".js_cardSetBox").size()<1) {
      $(".js_cardSetBox").addClass('hidden');
    }
    
    // 隐藏菜单设置弹框
    if (!$(s).is('.js_setBtn') && !$(s).is('.js_menuSetBox') && $(s).parents(".js_menuSetBox").size()<1 && !$(s).is('.js_addNewContent') && $(s).parents(".js_addNewContent").size()<1) {
      $(".js_menuSetBox").hide();
    }
    
    // 隐藏表情弹框
    if (!$(s).is('#weiboface') && $(s).parents("#weiboface").size()<1 && !$(s).is('.js_faceBtn') && $(s).parents(".js_faceBtn").size()<1) {
      $("#weiboface").hide();
    }
    
    // 隐藏首页二维码
    if (!$(s).is('.js_mPreviewBtn') && $(s).parents(".js_mPreviewBtn").size()<1 && !$(s).is('.js_mPreviewBox') && $(s).parents(".js_mPreviewBox").size()<1) {
      $(".js_mPreviewBox").hide();
    }
    
    // 隐藏颜色框
    if (!$(s).is('.js_selectColorBtn') && $(s).parents(".js_selectColorBtn").size()<1 && !$(s).is('.js_selectColorBox') && $(s).parents(".js_selectColorBox").size()<1) {
      $(".js_selectColorBox").hide();
    }
    
    // 隐藏图标框
    if (!$(s).is('.js_selectIconBtn') && $(s).parents(".js_selectIconBtn").size()<1 && !$(s).is('.js_selectIconBox') && $(s).parents(".js_selectIconBox").size()<1) {
      $(".js_selectIconBox").hide();
    }
  });

    layui.use(['form', 'laypage'], function () {
        var form = layui.form
            , laypage = layui.laypage;

        laypage.render({ //分页
            elem: 'pages'
            , count: "<?php echo htmlentities($list['total']); ?>"
            , theme: '#FFB800'
            , limit: "<?php echo htmlentities($list['per_page']); ?>"
            , curr: "<?php echo htmlentities($list['current_page']); ?>"
            , jump:function(obj, first) {
                if (!first) {
                    //location.href = "?page="+obj.curr
                    var query = window.location.href;

                    var url = query.split("?")[0]+"?page="+obj.curr;
                    location.href = url;
                }
            }
        });
    });
});
</script>
</body>
</html>